﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace RStein.PosterousReader.Common.SpecialOperations
{

  public interface IOperation
  {
    Action Operation
    {
      get;
    }

    Action PreviousOperation
    {
      get;
    }
    
    Action DisposeAction
    {
      get;
    }
    
    bool Completed
    {
      get;
    }

    bool Running
    {
      get;
    }

    bool HasException
    {
      get;
    }

    Exception Exception
    {
      get;
    }

    SynchronizationContext SynchronizationContext
    {
      get;
    }

    IOperation ContinueWith(IOperation operation);
    IOperation ContinueWith(IOperation operation, Action<IOperation, Exception> exceptionHandler);
    IOperation ContinueWith(IOperation operation, IOperation exceptionHandler);
    IOperation ContinueWith(IOperation operation, IOperation exceptionHandler, SynchronizationContext synchContext);
    IOperation ContinueWith(IOperation operation, Action<IOperation, Exception> exceptionHandler, SynchronizationContext synchContext);
    IOperation ContinueWith(Action action);
    IOperation ContinueWith(Action action, Action<IOperation, Exception> exceptionHandler);    
    IOperation ContinueWith(Action action, Action<IOperation, Exception> exceptionHandler, SynchronizationContext synchContext);    
    IOperation InCurrentSynchronizationContext();
    IOperation InSynchronizationContext(SynchronizationContext synchContext);    
    IOperation WithDisposeAction(Action DisposeAction);
    IOperation WithExceptionHandler(Action DisposeAction);
    void Run();
  }
}
